package com.pacifictextiles.qc.inspection.server.model.test;
import com.pacifictextiles.qc.inspection.server.model.dao.impl.BatchDAOImpl;
import com.pacifictextiles.qc.inspection.server.model.vo.Batch;

public class testAddBatch {
	public static void main(String[] args) {

		//new an interface
		BatchDAOImpl testBatchDAOImpl = new BatchDAOImpl();

		//set instance variable of batch
		Batch batch = new Batch();
		batch.setFabricType('1');
		batch.setDispoNo("1");
		batch.setBatchNo("1");
		batch.setRepairNo("1");
		batch.setColorCode("1");
		batch.setFabricCode("1");
		batch.setDispoLineNo("1");
		batch.setCustomerCode("1");
		batch.setFullCode("6");
		batch.setCustomerPO("11");
		batch.setShipSample(0);
		batch.setShrinkageSample(0);
		batch.setPieceSample(0);
		batch.setPpSample(0);
		batch.setQualityTable("11");

		/* add OK */
		try {
			testBatchDAOImpl.addBatch(batch);
		} catch (Exception e) {e.printStackTrace();}

		/* delete OK */
		try {
			testBatchDAOImpl.deleteBatch("6");
		} catch (Exception e) {e.printStackTrace();}

		/* get list */
		try {
			// new 一个batch 对象来测试接收Batch 对象

			Batch BatchPrint = new Batch();
			BatchPrint = testBatchDAOImpl.getBatch("11");
			printBatch(BatchPrint);

			// 判断有无查询到结果
			if (BatchPrint == null) {
				System.out.print("print:  没有查询到 Batch的信息" + "\n");
			}

		} catch (Exception e) {
			// e.printStackTrace();
			System.out.print("print:  获取Batch失败" + "\n");
		}

	}//main method

	
	private static void printBatch(Batch batch) throws Exception {
		try{
		
			System.out.print(batch.getFabricType() + "\n" + batch.getDispoNo()
				+ "\n" + batch.getBatchNo() + "\n" + batch.getRepairNo() + "\n"
				+ batch.getColorCode() + "\n" + batch.getFabricCode() + "\n"
				+ batch.getDispoLineNo() + "\n" + batch.getCustomerCode()
				+ "\n" + batch.getFullCode() + "\n" + batch.getCustomerPO()
				+ "\n" + batch.getShipSample() + "\n"
				+ batch.getShrinkageSample() + "\n" + batch.getPieceSample()
				+ "\n" + batch.getPpSample() + "\n\n\n");
		}catch (Exception e){
			
		}
	}
}
